import { getStorage, setStorage } from '@/utils/Storage'


export const useUserStore = defineStore('user', () => {
  const token = ref('')
  const setToken = (newToken: string) => {
    token.value = newToken
  }
  const clearToken = () => {
    setToken('')
  }
  return {
    token,
    setToken,
    clearToken,
  }
}, {
  persist: {
    key: 'user',
    storage: {
      getItem: (key: string) => getStorage(key),
      setItem: (key: string, value: string) => setStorage(key, value),
    }
  }
});
